package com.jsu.exhibitor.controller.v1;

import com.jsu.exhibitor.service.impl.ExpertServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.A;
import org.example.model.common.dtos.ResponseResult;
import org.example.model.exhibitor.pojos.Expert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/exhibitor/web/v1/expert")
@Api(tags = "专家信息控制器")
public class ExpertController {
    @Autowired
    private ExpertServiceImpl expertService;

    @GetMapping("/get/all")
    @ApiOperation(value = "获取所有专家信息")
    public ResponseResult getAllExpert(){
        return expertService.getAllExpert();
    }

    @ApiOperation(value = "根据ID获取专家信息")
    @GetMapping("/get/{id}")
    public ResponseResult getExpert(@PathVariable Integer id){
        return expertService.getExpert(id);
    }

    @ApiOperation(value = "添加专家信息")
    @PostMapping("/add")
    public ResponseResult addExpert(@RequestBody Expert expert){
        return expertService.addExpert(expert);
    }

    @ApiOperation(value = "删除专家信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteExpert(@PathVariable Integer id){
        return expertService.deleteExpert(id);
    }

    @ApiOperation(value = "更新专家信息")
    @PostMapping("/update")
    public ResponseResult updateExpert(@RequestBody Expert expert){
        return expertService.updateExpert(expert);
    }

    @ApiOperation(value = "模糊查询专家信息")
    @GetMapping("/search/{keyword}")
    public ResponseResult searchExpert(@PathVariable String keyword){
        return expertService.searchExpert(keyword);
    }

    @ApiOperation(value = "批量删除专家信息")
    @DeleteMapping("/delete/batch")
    public ResponseResult deleteExperts(@RequestBody Integer[] ids){
        return expertService.deleteExperts(ids);
    }


    @ApiOperation(value = "上传Excel文件")
    @PostMapping("/upload")
    public ResponseResult uploadExcel(@RequestParam("file") MultipartFile file) {
        return expertService.uploadExcel(file);
    }

    @ApiOperation(value = "导出Excel文件")
    @GetMapping("/export")
    public ResponseResult exportExcel(@RequestParam("fileName") String fileName) {
        return expertService.exportExcel(fileName);
    }
}
